package skeleton
{
	public class AccelerometerStatus
	{
		private var _allowMask:int;
		
		private var _cbSwitchToKeyboard:Function;
		private var _cdSwitchToAccelerometer:Function;
		
		private var _inputMode:int = MODE_UNKNOWN;
		public static const MODE_UNKNOWN:int = 0;
		public static const MODE_KEYBOARD:int = 1 << 0;
		public static const MODE_ACCELEROMETER:int = 1 << 1;
		public static const MODE_ALL:int = ~0;
		
		public function AccelerometerStatus(allowMask:int, cbSwitchToKeyboard:Function, cdSwitchToAccelerometer:Function)
		{
			_allowMask = allowMask;
			
			_cbSwitchToKeyboard = cbSwitchToKeyboard;
			_cdSwitchToAccelerometer = cdSwitchToAccelerometer;
		}
		
		public function getInputMode():int
		{
			return _inputMode;
		}
		
		public function switchToKeyboard():void
		{
			if((_allowMask & MODE_KEYBOARD) != 0)
			{
				_inputMode = MODE_KEYBOARD;
				if(_cbSwitchToKeyboard != null)
				{
					_cbSwitchToKeyboard();
				}
			}
		}
		
		public function switchToAccelerometer():void
		{
			if((_allowMask & MODE_ACCELEROMETER) != 0)
			{
				_inputMode = MODE_ACCELEROMETER;
				if(_cdSwitchToAccelerometer != null)
				{
					_cdSwitchToAccelerometer();
				}
			}
		}
		
	}
}